﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace CSTest
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //ClientCommandMessagePublisher pub = new ClientCommandMessagePublisher();
            //bool init_success = pub.init();
            //if (!init_success)
            //{
            //    Console.WriteLine("Failed to initialize the publisher.");
            //    return;
            //}
            //byte command = 0;
            //while(command != 2)
            //{
            //    Console.WriteLine("Enter your command (0-2):");
            //    command = byte.Parse(Console.ReadLine());
            //    if(command<0 || command>2)
            //    {
            //        Console.WriteLine("Invalid command. Please enter a number between 0 and 2.");
            //        continue;
            //    }
            //    bool v = pub.publish(command);
            //}

            HandMessageSubscriber sub = new HandMessageSubscriber();
            bool init_success = sub.init();
            if (!init_success)
            {
                Console.WriteLine("Failed to initialize the subscriber.");
                return;
            }

            while (true)
            {
                if (sub.Avaliable)
                {
                    sub.Avaliable = false;
                    byte[] values = sub.DetValid;
                    //Console.WriteLine(values[0]);
                    byte[] warnings = sub.Warning;

                    for (int i = 0; i < 21; i++)
                    {
                        for (int j = 0; j < 3; j++)
                        {
                            Console.Write($"Left: {sub.JointsL[i][j]} ");
                            Console.Write($"Right: {sub.JointsR[i][j]} ");
                            Console.Write($"{sub.Joints3DL[i][j]}");
                            Console.Write($"{sub.Joints3DR[i][j]}");
                        }
                        Console.WriteLine();
                    }

                    for (int i = 0; i < 778; i++)
                    {
                        for (int j = 0; j < 3; j++)
                        {
                            Console.Write($"Verts Left: {sub.Verts3DL[i][j]} ");
                            Console.Write($"Verts Right: {sub.Verts3DR[i][j]} ");
                        }
                        Console.WriteLine();
                    }
                }
            }
            Console.WriteLine("wait key to exit");
            Console.ReadKey();
        }
    }
}
